<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<ui:composition template="/WEB-INF/templates/padrao.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="cabecalho">
		<ui:include src="/WEB-INF/templates/menuBibli.xhtml" />
	</ui:define>


	<ui:define name="titulo">
		<h2 style="text-align: center">Pesquisa/Despache Reservas de Livros</h2>
	</ui:define>


	<ui:define name="conteudo">
		<div class="hero-unit">

			<h:panelGroup
				rendered="#{pesquisaDespachaReservaLivroBean.msg.wmsg}">
				<div class="alert alert-block">
					<button type="button" class="close" data-dismiss="alert">x</button>
					<h4>Atenção!</h4>
					#{pesquisaDespachaReservaLivroBean.msg.warningMsg}
				</div>
			</h:panelGroup>


			<h:panelGroup
				rendered="#{pesquisaDespachaReservaLivroBean.msg.emsg}">
				<div class="alert alert-error">
					<button type="button" class="close" data-dismiss="alert">x</button>
					<h4>Erro!</h4>
					#{pesquisaDespachaReservaLivroBean.msg.erroMsg}
				</div>
			</h:panelGroup>



			<h:panelGroup
				rendered="#{pesquisaDespachaReservaLivroBean.msg.smsg}">
				<div class="alert alert-success">
					<button type="button" class="close" data-dismiss="alert">x</button>
					<h4>Sucesso!</h4>
					#{pesquisaDespachaReservaLivroBean.msg.sucessMsg}
				</div>
			</h:panelGroup>


			<h:form class="form-signin" id="def">

				<fieldset>
					<legend style="color: blue">Definição de Pesquisa</legend>

					<h:panelGrid columns="2">

						<p:outputLabel value="Palavra Chave: " for="pc" />
						<h:inputText id="pc" label="Palavra Chave: "
							value="#{pesquisaDespachaReservaLivroBean.palavraChave}"
							required="true" requiredMessage="*A Palavra Chave é obrigatório!">
						</h:inputText>


						<p:outputLabel value="Termo de Pesquisa: " for="tp" />
						<h:selectOneMenu id="tp" label="Termo de Pesquisa: "
							value="#{pesquisaDespachaReservaLivroBean.termoPesquisa}"
							required="true"
							requiredMessage="*O Tipo de Usuário é obrigatório!">
							<f:selectItem itemLabel="--Selecione--" itemValue="Selecione" />
							<f:selectItems value="#{termoPesqBean.termoPesqReserva}" />
						</h:selectOneMenu>





					</h:panelGrid>

					<h:commandButton
						action="#{pesquisaDespachaReservaLivroBean.pesqReservaLivro}"
						value="Pesquisar" class="btn btn-large btn-primary" for="def" />

				</fieldset>

			</h:form>


			<h:dataTable
				styleClass="table table-striped table-bordered table-hover"
				value="#{pesquisaDespachaReservaLivroBean.reservasLivros}"
				var="reservaLivro"
				rendered="#{not empty pesquisaDespachaReservaLivroBean.reservasLivros}">
				<h:column>
					<f:facet name="header">
						<h:outputText value="Nº da Reserva" />
					</f:facet>
					<h:outputText value="#{reservaLivro.id_reserva}" />
				</h:column>


				<h:column>
					<f:facet name="header">
						<h:outputText value="Id do Usuario" />
					</f:facet>
					<h:outputText value="#{reservaLivro.usuario.id_usuario}" />
				</h:column>



				<h:column>
					<f:facet name="header">
						<h:outputText value="Código do Livro" />
					</f:facet>
					<h:outputText value="#{reservaLivro.livro.cod_item}" />
				</h:column>

				<h:column>
					<f:facet name="header">
						<h:outputText value="Status" />
					</f:facet>
					<h:outputText value="#{reservaLivro.statusReserva}" />
				</h:column>

				<h:column>
					<f:facet name="header">
						<h:outputText value="Data da Reserva" />
					</f:facet>
					<h:outputText value="#{reservaLivro.dt_reserva}" />
				</h:column>





				<h:column style="width:4%">
					<h:form>
						<h:commandButton id="btnDespachar"
							action="#{pesquisaDespachaReservaLivroBean.Despachar(reservaLivro)}"
							ajax="false" title="Despachar" value="Despachar" immediate="true">

							<f:setPropertyActionListener value="#{reservaLivro}"
								target="#{pesquisaReservaLivroBean.despache}" for="btnDespachar" />
						</h:commandButton>
					</h:form>
				</h:column>


			</h:dataTable>


		</div>
	</ui:define>
</ui:composition>